//
//  VCDownloadTs.h
//  VC
//
//  Created by 肖康龙 on 2017/8/30.
//  Copyright © 2017年 vsoontech. All rights reserved.
//

#import <Foundation/Foundation.h>
@class VCDownloadTs,VCTsDataModel;

@protocol VCDownloadTsDelegate <NSObject>

/**数据下载完毕回调
 *completeWithDataModel :数据
 */
-(void)download:(VCDownloadTs *)downloadTs completeWithDataModel:(VCTsDataModel *)model;
/**辅助下载完毕回调
 *auxiliaryCompleteWithDataModel :数据
 */
-(void)download:(VCDownloadTs *)downloadTs auxiliaryCompleteWithDataModel:(VCTsDataModel *)model;
/**调试界面,返回当前完成第几个包
 *completeIndex :第几个包
 */
-(void)download:(VCDownloadTs *)downloadTs bitmap:(NSData *)bitmap;
/**调试界面,返回当前完成第几个包
 *completeIndex :第几个包
 */
-(void)download:(VCDownloadTs *)downloadTs completeIndex:(NSUInteger)completeIndex;

/**调试界面,返回当前完成第几个包
 *downloadTs :ts下载器
 */
-(void)download:(VCDownloadTs *)downloadTs
         bitMap:(NSData *)bitMap;
/**调试界面,返回当前完成第几个包
 *downloadTs :ts下载器
 */
-(void)download:(VCDownloadTs *)downloadTs
instantaneousSpeed:(NSUInteger)instantaneousSpeed
  downloadTotal:(NSUInteger)downloadTotal
       tunnelId:(NSInteger)tunnelId
          state:(int)state;
@end


@interface VCDownloadTs : NSObject

@property (nonatomic,weak)id<VCDownloadTsDelegate>delegate;

/**1:正在被需要辅助的 2.第一个辅助 3.最后一个辅助*/
@property (nonatomic,assign)int auxiliaryOrder;
/**是否是帮助下载*/
@property (nonatomic,assign)BOOL isAuxiliaryDownload;
/**辅助下载需要说明的开始和结束点*/
/**开始点*/
@property (nonatomic,assign)NSUInteger startPoint;
/**结束点*/
@property (nonatomic,assign)NSUInteger endPoint;



/**是第几个ts*/
@property (nonatomic,assign)NSUInteger currentTsNum;
/**在字典获取出来的信息*/
@property (nonatomic,strong)NSString *hostAndPort;
/**地址*/
@property (nonatomic,strong)NSString *host;
/**端口号*/
@property (nonatomic,assign)NSUInteger prot;
/**我们打通道的端口*/
@property (nonatomic,assign)NSUInteger clientProt;
/**我们下载ts的端口*/
@property (nonatomic,assign)NSUInteger clientTSProt;
/**每一个ts的信息*/
@property (nonatomic,strong)NSDictionary *dict_file;
/**是否是空闲的*/
@property (nonatomic,assign)BOOL isFree;
/**总下来流量*/
@property (nonatomic,assign)NSUInteger tSize;
/**开始时间*/
@property (nonatomic,assign)NSTimeInterval timer;

/**开始下载 正常下载*/
-(void)startDownload;
/**开始下载 辅助下载*/
-(void)auxiliaryStartDownload;
/**是否需要辅助下载*/
-(BOOL)isNeedAuxiliary;

/**返回需要辅助的开始点*/
-(NSUInteger)auxiliaryStartPoint;
/**先获取end 在获取start 否则结束时间不正确,放回需要辅助的结束点*/
-(NSUInteger)auxiliaryEndPoint;

/**关闭下载器*/
-(void)closeDownload;
/**停止下载当前的ts*/
-(void)stopDownloadTs;

/**查看当前ts下载进度 百分比,100为下载完毕*/
-(int)getTsDownloadProgress;
@end
